
//

#import "LoadingConfigView.h"
//#import "NSIndexPath+helper.h"

#ifndef Macro_h
#define Macro_h

// 颜色相关
#define kRGB(r, g, b)  [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define kRGBA(r, g, b, a)  [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define kHexColor(rgbValue)  [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/256.0 green:((float)((rgbValue & 0xFF00) >> 8))/256.0 blue:((float)(rgbValue & 0xFF))/256.0 alpha:1.0]
#define kHexColorA(rgbValue, a)  [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/256.0 green:((float)((rgbValue & 0xFF00) >> 8))/256.0 blue:((float)(rgbValue & 0xFF))/256.0 alpha:a]

// 屏幕相关
#define kScreenW    [UIScreen mainScreen].bounds.size.width
#define kScreenH    [UIScreen mainScreen].bounds.size.height
#define kScale(value)  value * ((kScreenW / 320) > 1.2 ? 1.2 : (kScreenW / 320))
#define kScaleImage(value)  value * kScreenW / 320

#define KnavigationHeight [HSTool navBarHeight]
#define KstatusbarHeight ([HSTool statusbarHeight])
#define KtabHeight [HSTool tabBarHeight]

// 日志输出
#ifdef DEBUG
#define HSLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String])
#else
#define HSLog(...)
#endif

#define kFilePathWithName(fileName) [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:fileName]

//临时文件
#define kFileTempPathWithName(fileName) [NSTemporaryDirectory() stringByAppendingPathComponent:fileName]

//临时图片存储
#define kFileTempImagePathWithName(fileName) [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"tempImage/%@",fileName]]

// 其他
#define kWeakSelf   __weak typeof(self) weakSelf = self;
// 移除iOS7之后，cell默认左侧的分割线边距
#define kRemoveCellSeparator \
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{\
cell.separatorInset = UIEdgeInsetsZero;\
cell.layoutMargins = UIEdgeInsetsZero; \
cell.preservesSuperviewLayoutMargins = NO; \
}

// 字体相关
#define kAutoSysFont(fontSize)      [UIFont systemFontOfSize:fontSize]
#define kAutoSysBoldFont(fontSize)  [UIFont boldSystemFontOfSize:fontSize]
//#define KPingFangFont(fontSize) [UIFont fontWithName:@".PingFang-SC-Light" size:fontSize]
// 提示
#define kShowAlertMsg(_message_) UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:_message_ delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; \
[alert show];\

//#define kShowMsg(message)  [Helper showTips:message forTime:1 inView:nil yOffset:0]
//#define kShowMsgForTime(message, time)  [Helper showTips:message forTime:time inView:nil yOffset:0]

#define kShowLoadingView(view)     [[LoadingConfigView new] showLoadingView:view offsetY:0];
#define kShowLoadingTextView(view, text)     [[LoadingConfigView new] showLoadingText:text View:view];
#define kHideLoadingView(view)     [[LoadingConfigView new] hideLoadingView:view];
#define kAutoHideLoadingView(view,text,time) [[LoadingConfigView new] showLoadingText:text View:view hideTime:time];
#define kAutoShortHideLoadingView(text) [[LoadingConfigView new] showLoadingText:text View:self.view hideTime:0.5];

#define kShowAnimationLoadingView(view)    [[LoadingConfigView new] showAnimationView:view];
#define kHideAnimationLoadingView(view)    [[LoadingConfigView new] hideAnimationLoadingView:view];

//APP版本号
#define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//APP BundleVersion
#define kAppBundleVersion [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] intValue]

//系统版本号
#define kSystemVersion  [[[UIDevice currentDevice] systemVersion] floatValue]

#define kSystemVersionIOS11  (kSystemVersion >= 11.0)

//字符串是否为空
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//数组是否为空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否为空
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
//是否是空对象
#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

#endif
